//渠道
ascription2()
function ascription2() {
    $.ajax({
        type: "post",
        url: root.dockingplatform.queryAllInterfaceType,
        cache: false,  //禁用缓存
        dataType: "json",
        data: {
        },
        success: function (data) {
            console.log(data)
            if(data.errorCode=="0") {
                var dataInter=data.data;
                var interText = doT.template($("#ascription_bob").text());
                $("#ascription_lsit").html(interText(dataInter));
            }
            if (sessionStorage.getItem("interfaceCode")!=null){
                $("#ascription_lsit").val(sessionStorage.getItem("interfaceCode"));
                sessionStorage.removeItem("interfaceCode");
            }
        },
        error: function () {
            $.Huimodalalert('失败！',2000);
        }
    });


}

function  chooseProject(){
    var chooseData={
        "projectId":$("#projectId").val(), //项目编码
        "projectName":$("#projectName").val(), //项目名称
        "projectBelongName":$("#projectBelongName").val(),//所属分公司
        "receiverCompanyName":$("#receiverCompanyName").val(),//收货公司名称
        "invoiceCompanyName":$("#invoiceCompanyName").val(),//开票公司名称
    };
    localStorage.setItem("chooseData",JSON.stringify(chooseData));
    layer_show('选择渠道','chooseChannel.html', 1200, 445);
}
//保存

function saveInterface(){
    console.log(typeof($("#ascription_lsit").val()));
    if($("#ascription_lsit").val()==''){
        $.Huimodalalert("录入必填信息！",2000);
        return false;
    }

        $.ajax({
            url:root.dockingplatform.addChannelInterface,
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            contentType: "application/json",
            data: JSON.stringify({
                "channelId": parseInt(sessionStorage.getItem("id")),
                "interfaceName": $("#ascription_lsit").find("option:selected").text(),
                "interfaceCode": parseInt($("#ascription_lsit").val()),
                "interfaceUrl": $("#interfaceUrl").val(),
            }),
            success: function (data) {
                if(data.errorCode==0){
                    showmsg("保存成功",6);
                    //$.Huimodalalert('保存成功！',2000);
                    // var index = parent.layer.getFrameIndex(window.name);
                    // parent.layer.close(index);
                }else {
                    $.Huimodalalert(data.msg,2000);
                }
            },
            error: function () {
                $.Huimodalalert('保存失败！',2000);
            }
        })
}

// 提示信息
function showmsg(msg,icon){
    layer.msg(msg, {
        icon:icon,
        time: 1000
    },function(){
        if(icon==6){
            var index = parent.location.reload();
            parent.layer.close(index);
        }
    });
}

function getChannelCode() {
    alert(1)
    $.ajax({
        url:root.dockingplatform.saveSubChannelConfigInfo,
        cache: false,  //禁用缓存
        type: "POST",
        dataType:'json',
        contentType: "application/json",
        data: JSON.stringify({
            "customerId": $("#customerId").val(),
        }),
        success: function (data) {
            if(data.errorCode==0){
                $("#customerId").val(localStorage.getItem("choosecustomerId"));
            }else {
                $.Huimodalalert(data.msg,2000);
            }
        },
        error: function () {
            $.Huimodalalert('保存失败！',2000);
        }
    })
}